#pragma once

#include <windows.h>
#include <objbase.h>
#include <MMReg.h>
#include "dsound.h"


class CDsoundOutput
{
protected:
	BOOL m_fIsVista;
	BOOL Init(void);
	void Deinit(void);
private:
	PVOID m_p1;
	PVOID m_p2;
	DWORD m_l1;
	DWORD m_l2;
	BOOL m_fFirst;

public:	
	CDsoundOutput(void);
	~CDsoundOutput(void);

	GUID guidDev[16];
	char m_pszLDevNames[16][128];
	WAVEFORMATEXTENSIBLE m_wfx;
	int m_iCurLDev;
	int m_nLDevs;
	bool m_fInited;
	LPDIRECTSOUND8 m_pDS;
	DSBUFFERDESC m_dsbdesc; 
	LPDIRECTSOUNDBUFFER m_pDsb;
	LPDIRECTSOUNDBUFFER8 m_pDsb8;
	BOOL m_fEnable3D;
	BOOL m_fIsRun;
	HANDLE m_hMainBufferEvent[2];
	DWORD m_dwBufferSize;
	
	BOOL SetFormat(WAVEFORMATEXTENSIBLE* pwfx);
	BOOL SetDevice(int i);
	BOOL Start(void);
	void Stop(void);
	BOOL SetBufferSize(DWORD sz);
	BOOL FillMainBuffer(PBYTE pData, int iBufIndex);
};
